game_manager
{
// script for v3.0.2
// accum 4 : 1=stolen tank msg already broadcast

// globalaccum 0 bit 0	Set on the death of the glider; enables the alertentity to request rebirth; never reset
// globalaccum 0 bit 1  Set when the pump is operating; reset when the pump is disabled
// globalaccum 0 bit 2  0=Ramp unbuilt  1=Ramp built
// globalaccum 0 bit 3  0=Generator ok  1=Generator destroyed
// globalaccum 0 bit 4  1=Ruins CP built
// globalaccum 0 bit 5  1=Parachuting finished
// globalaccum 0 bit 6  0=Axis parachuting 1=Allies parachuting
// globalaccum 0 bit 7  1=Guardpost permanently allies, outpost to axis
// globalaccum 0 bit 8  0=axis own tank garage 1=allies
// globalaccum 1		Nbr of mortar group firing
// globalaccum 3		Tank location (mirror of local accum 3)

	spawn
	{
		// Game rules
		wm_axis_respawntime	20
		wm_allied_respawntime	10

		wm_set_round_timelimit	15
		wm_number_of_objectives 8

		// Objectives
		// 1: Repair the Hopper Pump
		// 2: Build a Glider
		// 3: Destroy the compound generator
		// 4: Steal the tank
		// 5: Get the tank to the Outpost
		// 6: Capture the Outpost
		// 7: Allied Command Post
		// 8: Axis Command Post

		// obj nbr, team, status (0=none, 1=passed, 2=failed)
		wm_objective_status 1 0 0
		wm_objective_status 1 1 0
		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
		wm_objective_status 4 0 0
		wm_objective_status 4 1 0
		wm_objective_status 5 0 0
		wm_objective_status 5 1 0
		wm_objective_status 6 0 0
		wm_objective_status 6 1 0
		wm_objective_status 7 0 0
		wm_objective_status 7 1 0
		wm_objective_status 8 0 0
		wm_objective_status 8 1 0

		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	0

		wait 500
		setautospawn "Outpost"		0		// Set Axis to Outpost spawn
		//setautospawn "Parachute"	1		// Set Allies to Parachute spawn
		setautospawn "Guardpost" 1

		setstate garage_wobj invisible		// Allied only
		setstate guardpost_wobj default		// Either
		setstate island_wobj invisible		// Axis only
		setstate ruins_wobj invisible			// Allied only
		setstate parachute_wobj invisible

		accum 4 set 0 // have the Allies stolen the tank?
		globalaccum 0 bitset 6 // Allies parachuting

		// start triggered loops on/off as required (eg: command post radio sounds)
		disablespeaker allies_compost_sound
		disablespeaker axis_compost_sound

		disablespeaker speaker_me109
		disablespeaker speaker_pump
		disablespeaker speaker_rocket_fire
		disablespeaker speaker_rocket_load
		disablespeaker speaker_rocket_resupply
		disablespeaker speaker_spitfire
		disablespeaker speaker_steam_hiss
		disablespeaker tank_sound
		trigger tank tank sound_stop

		setstate hint_call_hq_tm invisible
		setstate hint_me109_warning_tm invisible

		setstate bomb1 invisible
		setstate bomb2 invisible
		setstate bomb3 invisible
		setstate bomb4 invisible
		setstate bomb5 invisible
		setstate bomb6 invisible
		setstate bomb7 invisible
		setstate bomb8 invisible
		setstate bomb9 invisible
		setstate bomb10 invisible
		setstate bomb11 invisible
		setstate bomb12 invisible
		setstate bomb13 invisible
		setstate bomb14 invisible
		setstate bomb15 invisible
		setstate bomb16 invisible
		setstate bomb17 invisible
		setstate bomb18 invisible
		setstate bomb19 invisible
		setstate bomb20 invisible

	//	Nebel stuff
		setstate rocket1_loaded invisible
		setstate rocket2_loaded invisible
		setstate rocket3_loaded invisible
		setstate rocket4_loaded invisible
		setstate rocket5_loaded invisible
		setstate rocket6_loaded invisible

	//	Can't fire (nebel empty) and can't supply (cart full)
		setstate nebel_fire_fiu invisible
		setstate nebel_resupply_tm invisible
		setstate nebel_resupply_arrow invisible

	//	Tank turret
		remapshader "models/mapobjects/tanks_sd/mg42turret" "models/mapobjects/tanks_sd/mg42turret_2"

		remapshaderflush

		setstate axisteamdoor1 invisible
		setstate depotdoor invisible
		setstate hint_generator_door invisible
		setstate hint_generator_door_tm invisible
		setstate axisconstruct_outpost_mg42_toi invisible
		setstate axisconstruct_outpost_mg42_materials invisible
		setstate axisconstruct_outpost_mg42_flag invisible
		setstate axisconstruct_outpost_mg42_clip invisible
		setstate axisconstruct_outpost_mg42_mg42 invisible
		setstate axisconstruct_guardpost_mg42_toi invisible
		setstate axisconstruct_guardpost_mg42_materials invisible
		setstate axisconstruct_guardpost_mg42_flag invisible
		setstate axisconstruct_guardpost_mg42_clip invisible
		setstate axisconstruct_guardpost_mg42_mg42 invisible
		setstate axisconstruct_guardpost_mg42_extra invisible
		setstate axisconstruct_guardpost_mg42 invisible
		setstate guardpost_flag invisible
		setstate defense1_flag invisible
		setstate defense1_materials invisible
		setstate defense1 invisible
		setstate defense1_toi invisible
		setstate defense2_flag invisible
		setstate defense2_materials invisible
		setstate defense2 invisible
		setstate defense2_toi invisible
		setstate tank_build invisible
		setstate tank_turret invisible
		setstate tank invisible
		setstate hint_tibet invisible
		construct alliedconstruct_glider
		construct alliedconstruct_pump
	}

	trigger allies_win
	{

		wm_objective_status 5 0 2
		wm_objective_status 5 1 1
	}

	trigger allies_steal_tank
	{
		accum 4 abort_if_not_equal 0

		wm_objective_status 4 0 2
		wm_objective_status 4 1 1

		accum 4 set 1
//		wm_set_main_objective		2	0
//		wm_set_main_objective		2	1

		trigger game_manager allies_steal_tank_allied_msg
		trigger game_manager allies_steal_tank_axis_msg

	}

	trigger allies_steal_tank_allied_msg
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_tank_stolen"
		wm_teamvoiceannounce 1 "goldrush_allies_tankbars_destroy"

		wm_removeteamvoiceannounce 1 "goldrush_allies_tank_steal"
		// *---------------------------------------------------------------------------------*
	}

	trigger allies_steal_tank_axis_msg
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_tank_stop"
		wm_addteamvoiceannounce 0 "goldrush_axis_tankbars_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_tank_stolen"
		wm_teamvoiceannounce 0 "goldrush_axis_tankbars_construct"

		wm_removeteamvoiceannounce 0 "goldrush_axis_tank_steal"
		// *---------------------------------------------------------------------------------*
	}

	trigger axis_win
	{
		wm_setwinner	0
		wm_announce "The Axis have stopped the Allies from photographing the tank!"

		wm_objective_status 5 0 1
		wm_objective_status 5 1 2

		wait 3000
		wm_endround
	}
}

// =================================================
// Allied Command Post - has special spawn script
// =================================================
allied_cp_open
{
	spawn
	{
		wait 100
		accum 0 set 0			// 0=CP Closed, 1=CP Damaged
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
		setstate allied_cp_damaged invisible	// Hide damaged CP clipbrush+model
		setstate allied_cp_damaged_model invisible
	}

	trigger disable_cp_features
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1

		sethqstatus 1 0			// Landmines team warning message
		disablespeaker allies_compost_sound		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		enablespeaker allies_compost_sound		// Enable morse code sound
		setstate allied_cp_open_model default	// Show open CP model

		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75

		sethqstatus 1 1			// Landmines team warning message
	}

	buildstart final
	{
		setstate allied_cp_closed invisible		// Hide closed CP clipbrush+model
		setstate allied_cp_closed_model invisible
		setstate allied_cp_damaged invisible	// Hide damaged CP clipbrush+model
		setstate allied_cp_damaged_model invisible
	}

	built final
	{
		accum 0 set 1			// Only show the damaged CP model
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "Allied Command Post constructed. Charge speed increased!"

		wm_objective_status 7 0 2
		wm_objective_status 7 1 1

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_addteamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		// *----------------------------------- vo ------------------------------------------*

		globalaccum 0 abort_if_bitset 4
		globalaccum 0 bitset 4

	//	Tell them to build ramp
		trigger self ramp_alert

	//	Reveal the ramp crates
		setstate alliedconstruct_ramp_toi default
		trigger alliedconstruct_ramp setup

	//	Remove Outpost flag
		setstate outpost_flag invisible
		setstate outpost_wobj invisible

	//	Make Ruins the allied spawn
		setstate ruins_wobj default
		alertentity ruins_spawns
		wm_announce "^3Allies can now spawn at the Ruins!"

	//	Set both teams to 20 sec respawn
		wm_axis_respawntime 20
		wm_allied_respawntime 20

	//	Prevent any more parachuting
		setstate parachute_wobj invisible
		trigger self disable_axis_parachutes
		trigger self disable_allied_parachutes
		globalaccum 0 bitset 5 // Parachuting now finished

	//	Make Compound the axis spawn
		setautospawn "Compound" 0

		globalaccum 0 abort_if_bitset 7 // If the allies are permanently at guardpost, don't set allied spawn to Ruins
		setautospawn "Ruins" 1 //  Allies move to the ruins
	}

	trigger ramp_alert
	{
		globalaccum 0 abort_if_bitset 2 // Ramp is already built
		globalaccum 0 abort_if_bitset 3 // Generator is destroyed

		wm_teamvoiceannounce 0 "battery_axis_stop_ramp"
		wm_teamvoiceannounce 1 "battery_allies_build_ramp"
	}

	trigger disable_allied_parachutes
	{
		globalaccum 0 abort_if_bitset 5 // Parachuting already finished
		globalaccum 0 abort_if_not_bitset 6 // Abort if Axis parachuting
		alertentity allied_parachute_spawns
	}

	trigger disable_axis_parachutes
	{
		globalaccum 0 abort_if_bitset 5 // Parachuting already finished
		globalaccum 0 abort_if_bitset 6 // Abort if Allies parachuting
		alertentity axis_parachute_spawns
	}

	decayed final
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model
		trigger self show_damaged_cabinet	// Show previous cabinet state
		trigger self show_closed_cabinet
	}

	death
	{
		trigger self show_damaged_cabinet	// Show damaged CP model
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "Axis have destroyed the Allied Command Post!"

		wm_objective_status 7 0 1
		wm_objective_status 7 1 2

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger show_closed_cabinet
	{
		accum 0 abort_if_equal 1		// Closed cabinet active yet?
		setstate allied_cp_closed default
		setstate allied_cp_closed_model default
	}

	trigger show_damaged_cabinet
	{
		accum 0 abort_if_equal 0		// Damaged cabinet active yet?
		setstate allied_cp_damaged default
		setstate allied_cp_damaged_model default
	}
}

// =================================================
// Allied Construct: Glider
// =================================================
alliedconstruct_glider
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class		1
		constructible_chargebarreq	1.5
		constructible_constructxpbonus	10	// 5 7.5 10
		constructible_destructxpbonus		15	// 5 7.5 10
	}

	trigger setup
	{
		setstate alliedconstruct_glider_materials default	// Crate Models
		setstate alliedconstruct_glider_clip default		// Clip brushes
		setstate alliedconstruct_glider_flag default

		setstate glider_sm invisible
		setstate glider_tm invisible
	}

	buildstart final
	{
		trigger glider_sm respot
		setstate glider_sm underconstruction
	}

	built final
	{
		setstate alliedconstruct_glider_materials invisible	// Crate Models
		setstate alliedconstruct_glider_clip invisible	// Clip brushes
		setstate alliedconstruct_glider_flag invisible

		setstate glider_sm default
		setstate glider_tm default

		globalaccum 0 abort_if_not_bitset 0
		alertentity glider_sm
	}

	decayed final
	{
		trigger self setup
		setstate glider_sm invisible
	}

	death
	{
	// There is no death because the construct is a nodraw
	}
}

// =================================================
// Allied Construct: Pump
//	- It makes the hoppers move
//	- It enables gliders to be launched
// =================================================
alliedconstruct_pump
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class		3	// 1 2 3
	}

	trigger setup
	{
		setstate alliedconstruct_pump_materials default	// Crate Models
		setstate alliedconstruct_pump_clip default		// Clip brushes
		setstate alliedconstruct_pump_flag default

		setstate brokenpump default
	}

	buildstart final
	{
		setstate brokenpump invisible
	}

	built final
	{
		setstate alliedconstruct_pump_materials invisible	// Crate Models
		setstate alliedconstruct_pump_clip invisible	// Clip brushes
		setstate alliedconstruct_pump_flag invisible


		wm_objective_status 1 0 2
		wm_objective_status 1 1 1

		setstate pump_puff default
		enablespeaker speaker_pump
		enablespeaker speaker_steam_hiss
		globalaccum 0 bitset 1
		
		trigger bucket1_sm go
		trigger bucket2_sm go
		trigger bucket3_sm go
		trigger bucket4_sm go

	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		wm_announce "^3Axis have destroyed the Hopper Pump!"

		wm_objective_status 1 0 1
		wm_objective_status 1 1 2

		trigger self setup

		setstate pump_puff invisible
		disablespeaker speaker_pump
		disablespeaker speaker_steam_hiss
		globalaccum 0 bitreset 1

		trigger bucket1_sm stop
		trigger bucket2_sm stop
		trigger bucket3_sm stop
		trigger bucket4_sm stop

		wm_announce "^3Gliders can't be launched until it's repaired!"
	}
}

// =================================================
// Allied Construct: Ramp
// =================================================
alliedconstruct_ramp
{
	spawn
	{
		wait 50

	//	Hide crates until Ruins CP built
		setstate alliedconstruct_ramp_materials invisible	// Crate Models
		setstate alliedconstruct_ramp_clip invisible	// Clip brushes
		setstate alliedconstruct_ramp_flag invisible
		setstate alliedconstruct_ramp_toi invisible // remove the build hint

		constructible_class		2
	}

	trigger setup
	{
		globalaccum 0 abort_if_bitset 3 // Don't replace the boxes if the generator is destroyed

		setstate alliedconstruct_ramp_materials default	// Crate Models
		setstate alliedconstruct_ramp_clip default		// Clip brushes
		setstate alliedconstruct_ramp_flag default
	}

	built final
	{
		setstate alliedconstruct_ramp_materials invisible	// Crate Models
		setstate alliedconstruct_ramp_clip invisible	// Clip brushes
		setstate alliedconstruct_ramp_flag invisible

		wm_announce "^3The Allies have built the Assault Ramp!"
		globalaccum 0 bitset 2

		// ***********************
		wm_teamvoiceannounce 0 "battery_axis_built_ramp"
		wm_teamvoiceannounce 1 "battery_allies_built_ramp"
		// ***********************
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		wm_announce "^3Axis have destroyed the Assault Ramp!"
		globalaccum 0 bitreset 2

		// ***********************
		wm_teamvoiceannounce 0 "battery_axis_dest_ramp"
		wm_teamvoiceannounce 1 "battery_allies_dest_ramp"
		// ***********************

		trigger self setup

		globalaccum 0 abort_if_not_bitset 3 // abort if the generator is intact
		setstate alliedconstruct_ramp_toi invisible // remove the build hint
	}
}

// =================================================
// Axis Command Post
// =================================================
axis_cp_open
{
	spawn
	{
		wait 100
		accum 0 set 0			// 0=CP Closed, 1=CP Damaged
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
		setstate axis_cp_damaged invisible	// Hide damaged CP clipbrush+model
		setstate axis_cp_damaged_model invisible
	}

	trigger disable_cp_features
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1

		sethqstatus 0 0			// Landmines team warning message
		disablespeaker axis_compost_sound		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate axis_cp_open_model default	// Show open CP model

		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75

		sethqstatus 0 1			// Landmines team warning message
		enablespeaker axis_compost_sound		// Enable morse code sound
	}

	buildstart final
	{
		setstate axis_cp_closed invisible		// Hide closed CP clipbrush+model
		setstate axis_cp_closed_model invisible
		setstate axis_cp_damaged invisible	// Hide damaged CP clipbrush+model
		setstate axis_cp_damaged_model invisible
	}

	built final
	{
		accum 0 set 1			// Only show the damaged CP model
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "Axis Command Post constructed. Charge speed increased!"

		wm_objective_status 8 0 1
		wm_objective_status 8 1 2

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		wm_addteamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		// *----------------------------------- vo ------------------------------------------*
	}

	decayed final
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model
		trigger self show_damaged_cabinet	// Show previous cabinet state
		trigger self show_closed_cabinet
	}

	death
	{
		trigger self show_damaged_cabinet	// Show damaged CP model
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "Allies have destroyed the Axis Command Post!"

		wm_objective_status 8 0 2
		wm_objective_status 8 1 1

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_removeteamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger show_closed_cabinet
	{
		accum 0 abort_if_equal 1		// Closed cabinet active yet?
		setstate axis_cp_closed default
		setstate axis_cp_closed_model default
	}

	trigger show_damaged_cabinet
	{
		accum 0 abort_if_equal 0		// Damaged cabinet active yet?
		setstate axis_cp_damaged default
		setstate axis_cp_damaged_model default
	}
}

// =================================================
// Axis Construct: Guardpost MG42
// =================================================
axisconstruct_guardpost_mg42
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class 2			// Dyno+Satchel
	}

	trigger setup
	{
		setstate axisconstruct_guardpost_mg42_materials default	// Crate Models
		setstate axisconstruct_guardpost_mg42_clip default	// Clip brushes
		setstate axisconstruct_guardpost_mg42_flag default

		setstate axisconstruct_guardpost_mg42_extra invisible	// Sandbags
		setstate axisconstruct_guardpost_mg42_mg42 invisible	// MG42 entity
		repairmg42 axisconstruct_guardpost_mg42_mg42
	}

	built final
	{
		setstate axisconstruct_guardpost_mg42_materials invisible	// Crate Models
		setstate axisconstruct_guardpost_mg42_clip invisible	// Clip brushes
		setstate axisconstruct_guardpost_mg42_flag invisible

		setstate axisconstruct_guardpost_mg42_extra default	// Sandbags
		setstate axisconstruct_guardpost_mg42_mg42 default	// MG42 entity

		wm_announce "^3Axis have built the Guardpost MG42!"
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "^3Allies have destroyed the Guardpost MG42!" 
	}
}

// =================================================
// Axis Construct: Outpost MG42
// =================================================
axisconstruct_outpost_mg42
{
	spawn
	{
		wait 50
		trigger self setup
		constructible_class 2			// Dyno+Satchel
	}

	trigger setup
	{
		setstate axisconstruct_outpost_mg42_materials default	// Crate Models
		setstate axisconstruct_outpost_mg42_clip default	// Clip brushes
		setstate axisconstruct_outpost_mg42_flag default

		setstate axisconstruct_outpost_mg42_mg42 invisible	// MG42 entity
		repairmg42 axisconstruct_outpost_mg42_mg42
	}

	built final
	{
		setstate axisconstruct_outpost_mg42_materials invisible	// Crate Models
		setstate axisconstruct_outpost_mg42_clip invisible	// Clip brushes
		setstate axisconstruct_outpost_mg42_flag invisible

		setstate axisconstruct_outpost_mg42_mg42 default	// MG42 entity

		wm_announce "^3Axis have built the Outpost MG42!"
	}

	decayed final
	{
		trigger self setup
	}

	death
	{
		trigger self setup
		wm_announce "^3Allies have destroyed the Outpost MG42!" 
	}
}

// =================================================
// Buckets
// =================================================
bucket1_sm
{
// accum 0	: next waypoint marker
// accum 1	: 0=dead	1=alive
	spawn
	{
		wait 100
		faceangles 0 180 0 100
		accum 0 set 5
	}

	trigger go
	{
		stopsound
		playsound sound/vehicles/tug/tug_move.wav looping volume 32
		
		accum 1 set 1
		trigger self move
	}

	trigger stop
	{
		accum 1 set 0
		abortmove
		stopsound
	}

	trigger keep_moving
	{
		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self set_next_marker

		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self move
	}

	trigger move
	{
		accum 0 trigger_if_equal 1 bucket1_sm move1
		accum 0 trigger_if_equal 2 bucket1_sm move2
		accum 0 trigger_if_equal 3 bucket1_sm move3
		accum 0 trigger_if_equal 4 bucket1_sm move4
		accum 0 trigger_if_equal 5 bucket1_sm move5
		accum 0 trigger_if_equal 6 bucket1_sm move6
		accum 0 trigger_if_equal 7 bucket1_sm move7
		accum 0 trigger_if_equal 8 bucket1_sm move8
	}

	trigger set_next_marker
	{
		accum 0 inc 1
		accum 0 abort_if_less_than 9
		accum 0 set 1
	}

	trigger move1
	{
		gotomarker bucket_path1 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 90 0 1000
		trigger self keep_moving
	}

	trigger move2
	{
		gotomarker bucket_path2 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 180 0 1000
		trigger self keep_moving
	}

	trigger move3
	{
		gotomarker bucket_path3 100 wait
		trigger self keep_moving
	}

	trigger move4
	{
		gotomarker bucket_path4 100 wait
		trigger self keep_moving
	}

	trigger move5
	{
		gotomarker bucket_path5 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 270 0 1000
		trigger self keep_moving
	}

	trigger move6
	{
		gotomarker bucket_path6 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 0 0 1000
		trigger self keep_moving
	}

	trigger move7
	{
		gotomarker bucket_path7 100 wait
		trigger self keep_moving
	}

	trigger move8
	{
		gotomarker bucket_path8 100 wait
		trigger self keep_moving
	}
}

bucket2_sm
{
// accum 0	: next waypoint marker
	spawn
	{
		wait 100
		faceangles 0 180 0 100
		accum 0 set 5
	}

	trigger go
	{
		stopsound
		playsound sound/vehicles/tug/tug_move.wav looping volume 32
		
		accum 1 set 1
		trigger self move
	}

	trigger stop
	{
		accum 1 set 0
		abortmove
		stopsound
	}

	trigger keep_moving
	{
		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self set_next_marker

		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self move
	}

	trigger move
	{
		accum 0 trigger_if_equal 1 bucket2_sm move1
		accum 0 trigger_if_equal 2 bucket2_sm move2
		accum 0 trigger_if_equal 3 bucket2_sm move3
		accum 0 trigger_if_equal 4 bucket2_sm move4
		accum 0 trigger_if_equal 5 bucket2_sm move5
		accum 0 trigger_if_equal 6 bucket2_sm move6
		accum 0 trigger_if_equal 7 bucket2_sm move7
		accum 0 trigger_if_equal 8 bucket2_sm move8
	}

	trigger set_next_marker
	{
		accum 0 inc 1
		accum 0 abort_if_less_than 9
		accum 0 set 1
	}

	trigger move1
	{
		gotomarker bucket_path1 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 90 0 1000
		trigger self keep_moving
	}

	trigger move2
	{
		gotomarker bucket_path2 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 180 0 1000
		trigger self keep_moving
	}

	trigger move3
	{
		gotomarker bucket_path3 100 wait
		trigger self keep_moving
	}

	trigger move4
	{
		gotomarker bucket_path4 100 wait
		trigger self keep_moving
	}

	trigger move5
	{
		gotomarker bucket_path5 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 270 0 1000
		trigger self keep_moving
	}

	trigger move6
	{
		gotomarker bucket_path6 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 0 0 1000
		trigger self keep_moving
	}

	trigger move7
	{
		gotomarker bucket_path7 100 wait
		trigger self keep_moving
	}

	trigger move8
	{
		gotomarker bucket_path8 100 wait
		trigger self keep_moving
	}
}

bucket3_sm
{
// accum 0	: next waypoint marker
	spawn
	{
		wait 100
		accum 0 set 8
	}

	trigger go
	{
		stopsound
		playsound sound/vehicles/tug/tug_move.wav looping volume 32
		
		accum 1 set 1
		trigger self move
	}

	trigger stop
	{
		accum 1 set 0
		abortmove
		stopsound
	}

	trigger keep_moving
	{
		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self set_next_marker

		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self move
	}

	trigger move
	{
		accum 0 trigger_if_equal 1 bucket3_sm move1
		accum 0 trigger_if_equal 2 bucket3_sm move2
		accum 0 trigger_if_equal 3 bucket3_sm move3
		accum 0 trigger_if_equal 4 bucket3_sm move4
		accum 0 trigger_if_equal 5 bucket3_sm move5
		accum 0 trigger_if_equal 6 bucket3_sm move6
		accum 0 trigger_if_equal 7 bucket3_sm move7
		accum 0 trigger_if_equal 8 bucket3_sm move8
	}

	trigger set_next_marker
	{
		accum 0 inc 1
		accum 0 abort_if_less_than 9
		accum 0 set 1
	}

	trigger move1
	{
		gotomarker bucket_path1 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 90 0 1000
		trigger self keep_moving
	}

	trigger move2
	{
		gotomarker bucket_path2 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 180 0 1000
		trigger self keep_moving
	}

	trigger move3
	{
		gotomarker bucket_path3 100 wait
		trigger self keep_moving
	}

	trigger move4
	{
		gotomarker bucket_path4 100 wait
		trigger self keep_moving
	}

	trigger move5
	{
		gotomarker bucket_path5 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 270 0 1000
		trigger self keep_moving
	}

	trigger move6
	{
		gotomarker bucket_path6 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 0 0 1000
		trigger self keep_moving
	}

	trigger move7
	{
		gotomarker bucket_path7 100 wait
		trigger self keep_moving
	}

	trigger move8
	{
		gotomarker bucket_path8 100 wait
		trigger self keep_moving
	}
}

bucket4_sm
{
// accum 0	: next waypoint marker
	spawn
	{
		wait 100
		accum 0 set 7
	}

	trigger go
	{
		stopsound
		playsound sound/vehicles/tug/tug_move.wav looping volume 32
		
		accum 1 set 1
		trigger self move
	}

	trigger stop
	{
		accum 1 set 0
		abortmove
		stopsound
	}

	trigger keep_moving
	{
		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self set_next_marker

		accum 1 abort_if_equal 0 // stop moving if pump destroyed
		trigger self move
	}

	trigger move
	{
		accum 0 trigger_if_equal 1 bucket4_sm move1
		accum 0 trigger_if_equal 2 bucket4_sm move2
		accum 0 trigger_if_equal 3 bucket4_sm move3
		accum 0 trigger_if_equal 4 bucket4_sm move4
		accum 0 trigger_if_equal 5 bucket4_sm move5
		accum 0 trigger_if_equal 6 bucket4_sm move6
		accum 0 trigger_if_equal 7 bucket4_sm move7
		accum 0 trigger_if_equal 8 bucket4_sm move8
	}

	trigger set_next_marker
	{
		accum 0 inc 1
		accum 0 abort_if_less_than 9
		accum 0 set 1
	}

	trigger move1
	{
		gotomarker bucket_path1 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 90 0 1000
		trigger self keep_moving
	}

	trigger move2
	{
		gotomarker bucket_path2 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 180 0 1000
		trigger self keep_moving
	}

	trigger move3
	{
		gotomarker bucket_path3 100 wait
		trigger self keep_moving
	}

	trigger move4
	{
		gotomarker bucket_path4 100 wait
		trigger self keep_moving
	}

	trigger move5
	{
		gotomarker bucket_path5 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 270 0 1000
		trigger self keep_moving
	}

	trigger move6
	{
		gotomarker bucket_path6 100 wait
		accum 1 abort_if_equal 0 // stop moving if pump destroyed

		faceangles 0 0 0 1000
		trigger self keep_moving
	}

	trigger move7
	{
		gotomarker bucket_path7 100 wait
		trigger self keep_moving
	}

	trigger move8
	{
		gotomarker bucket_path8 100 wait
		trigger self keep_moving
	}
}

// =================================================
// Call Airstrike
// =================================================
call_airstrike_tst
{
// accum 0  : 0=Airstrike available  1=Airstrike in progress
// accum 1	: random (0-3)
// accum 2	: range required for subsequent airstrike
// accum 3	: tank in range? 0=No  1to9=range
// accum 4	: 0=Another airstrike permitted  1=Too close to previous airstrike
	trigger run
	{
		accum 0 abort_if_equal 1 // Airstrike in progress

		trigger self tank_range_check

		accum 3 abort_if_equal 0 // Completely out of range

		accum 4 set 0
		accum 3 trigger_if_equal 1 call_airstrike_tst check_range1
		accum 3 trigger_if_equal 2 call_airstrike_tst check_range2
		accum 3 trigger_if_equal 3 call_airstrike_tst check_range3
		accum 3 trigger_if_equal 4 call_airstrike_tst check_range4
		accum 3 trigger_if_equal 5 call_airstrike_tst check_range5
		accum 3 trigger_if_equal 6 call_airstrike_tst check_range6
		accum 3 trigger_if_equal 7 call_airstrike_tst check_range7
		accum 3 trigger_if_equal 8 call_airstrike_tst check_range8
		accum 3 trigger_if_equal 9 call_airstrike_tst check_range9

		trigger self calling_hq
		accum 4 abort_if_equal 1 // requested strike is too close to earlier strike

		accum 0 set 1 // Airstrike commencing
		setstate call_airstrike_tst invisible

		setstate hint_me109_warning_tm default
		wait random 4000 8000
		setstate hint_me109_warning_tm invisible

		disablespeaker speaker_me109
		enablespeaker speaker_me109
		wait 12000

		accum 1 random 4 // 1 bomb in 4 will not be detonated
		accum 3 trigger_if_equal 1 call_airstrike_tst range1
		accum 3 trigger_if_equal 2 call_airstrike_tst range2
		accum 3 trigger_if_equal 3 call_airstrike_tst range3
		accum 3 trigger_if_equal 4 call_airstrike_tst range4
		accum 3 trigger_if_equal 5 call_airstrike_tst range5
		accum 3 trigger_if_equal 6 call_airstrike_tst range6
		accum 3 trigger_if_equal 7 call_airstrike_tst range7
		accum 3 trigger_if_equal 8 call_airstrike_tst range8
		accum 3 trigger_if_equal 9 call_airstrike_tst range9
	}

	trigger calling_hq
	{
		accum 4 abort_if_equal 0 // Only show negative hq msg if request denied

		accum 0 set 1 // Stop triggering for the moment
		setstate call_airstrike_tst invisible

		setstate hint_call_hq_tm default
		trigger self reset
	}

	trigger reset
	{
		wait 5000
		setstate call_airstrike_tst default
		setstate hint_call_hq_tm invisible
		accum 0 set 0
	}

	trigger check_range1
	{
		accum 2 abort_if_less_than 2
		accum 4 set 1
	}

	trigger check_range2
	{
		accum 2 abort_if_less_than 3
		accum 4 set 1
	}

	trigger check_range3
	{
		accum 2 abort_if_less_than 4
		accum 4 set 1
	}

	trigger check_range4
	{
		accum 2 abort_if_less_than 5
		accum 4 set 1
	}

	trigger check_range5
	{
		accum 2 abort_if_less_than 6
		accum 4 set 1
	}

	trigger check_range6
	{
		accum 2 abort_if_less_than 7
		accum 4 set 1
	}

	trigger check_range7
	{
		accum 2 abort_if_less_than 8
		accum 4 set 1
	}

	trigger check_range8
	{
		accum 2 abort_if_less_than 9
		accum 4 set 1
	}

	trigger check_range9
	{
		accum 2 abort_if_less_than 10
		accum 4 set 1
	}

	trigger range1
	{
		accum 2 set 3 // Earliest range for another strike

		trigger self bomb1
		wait random 500 1500

		trigger self bomb2
		wait random 500 1500

		trigger self bomb3
		wait random 500 1500

		trigger self bomb4

		trigger self reset
	}

	trigger range2
	{
		accum 2 set 4

		trigger self bomb3
		wait random 500 1500

		trigger self bomb4
		wait random 500 1500

		trigger self bomb5
		wait random 500 1500

		trigger self bomb6

		trigger self reset
	}

	trigger range3
	{
		accum 2 set 5

		trigger self bomb5
		wait random 500 1500

		trigger self bomb6
		wait random 500 1500

		trigger self bomb7
		wait random 500 1500

		trigger self bomb8

		trigger self reset
	}

	trigger range4
	{
		accum 2 set 6

		trigger self bomb7
		wait random 500 1500

		trigger self bomb8
		wait random 500 1500

		trigger self bomb9
		wait random 500 1500

		trigger self bomb10

		trigger self reset
	}

	trigger range5
	{
		accum 2 set 7

		trigger self bomb9
		wait random 500 1500

		trigger self bomb10
		wait random 500 1500

		trigger self bomb11
		wait random 500 1500

		trigger self bomb12

		trigger self reset
	}

	trigger range6
	{
		accum 2 set 8

		trigger self bomb11
		wait random 500 1500

		trigger self bomb12
		wait random 500 1500

		trigger self bomb13
		wait random 500 1500

		trigger self bomb14

		trigger self reset
	}

	trigger range7
	{
		accum 2 set 9

		trigger self bomb13
		wait random 500 1500

		trigger self bomb14
		wait random 500 1500

		trigger self bomb15
		wait random 500 1500

		trigger self bomb16

		trigger self reset
	}

	trigger range8
	{
		accum 2 set 10

		trigger self bomb15
		wait random 500 1500

		trigger self bomb16
		wait random 500 1500

		trigger self bomb17
		wait random 500 1500

		trigger self bomb18

		trigger self reset
	}

	trigger range9
	{
		accum 2 set 11

		trigger self bomb17
		wait random 500 1500

		trigger self bomb18
		wait random 500 1500

		trigger self bomb19
		wait random 500 1500

		trigger self bomb20

		trigger self reset
	}

	trigger bomb1
	{
		accum 1 abort_if_equal 0
		alertentity bomb1
	}

	trigger bomb2
	{
		accum 1 abort_if_equal 1
		alertentity bomb2
	}

	trigger bomb3
	{
		accum 1 abort_if_equal 2
		alertentity bomb3
	}

	trigger bomb4
	{
		accum 1 abort_if_equal 3
		alertentity bomb4
	}
	
	trigger bomb5
	{
		accum 1 abort_if_equal 0
		alertentity bomb5
	}

	trigger bomb6
	{
		accum 1 abort_if_equal 1
		alertentity bomb6
	}

	trigger bomb7
	{
		accum 1 abort_if_equal 2
		alertentity bomb7
	}

	trigger bomb8
	{
		accum 1 abort_if_equal 3
		alertentity bomb8
	}

	trigger bomb9
	{
		accum 1 abort_if_equal 0
		alertentity bomb9
	}

	trigger bomb10
	{
		accum 1 abort_if_equal 1
		alertentity bomb10
	}

	trigger bomb11
	{
		accum 1 abort_if_equal 2
		alertentity bomb11
	}

	trigger bomb12
	{
		accum 1 abort_if_equal 3
		alertentity bomb12
	}

	trigger bomb13
	{
		accum 1 abort_if_equal 0
		alertentity bomb13
	}

	trigger bomb14
	{
		accum 1 abort_if_equal 1
		alertentity bomb14
	}

	trigger bomb15
	{
		accum 1 abort_if_equal 2
		alertentity bomb15
	}

	trigger bomb16
	{
		accum 1 abort_if_equal 3
		alertentity bomb16
	}

	trigger bomb17
	{
		accum 1 abort_if_equal 0
		alertentity bomb17
	}

	trigger bomb18
	{
		accum 1 abort_if_equal 1
		alertentity bomb18
	}

	trigger bomb19
	{
		accum 1 abort_if_equal 2
		alertentity bomb19
	}

	trigger bomb20
	{
		accum 1 abort_if_equal 3
		alertentity bomb20
	}

	trigger tank_range_check
	{
		globalaccum 3 abort_if_less_than 43 // Tank not yet past 2nd barrier
		globalaccum 3 abort_if_greater_than 83 // Tank gone too far

		// Set accum 3 to value to indicate where in range
		accum 3 set 1
		globalaccum 3 abort_if_less_than 50

		accum 3 set 2
		globalaccum 3 abort_if_less_than 54
		
		accum 3 set 3
		globalaccum 3 abort_if_less_than 57

		accum 3 set 4
		globalaccum 3 abort_if_less_than 62

		accum 3 set 5
		globalaccum 3 abort_if_less_than 68

		accum 3 set 6
		globalaccum 3 abort_if_less_than 73

		accum 3 set 7
		globalaccum 3 abort_if_less_than 76

		accum 3 set 8
		globalaccum 3 abort_if_less_than 80

		accum 3 set 9
	}
}

// =================================================
// Depot door
// =================================================
depotdoor
{
	spawn
	{
		wait 150
	}

	trigger open_door
	{
		stopsound
		playsound sound/movers/misc/garage_door_start_01.wav volume 512
		wait 1000

		stopsound
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512

		gotomarker depotdoor_open 15 wait

		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 512
	}
}

//===================================
exclamation
{
	spawn
	{
		wait 500
		setrotation 0 90 0
	}
}

// =================================================
// Generator
// =================================================
generator
{
	spawn
	{
		wait 100
		constructible_class 2
	}

	death
	{
		setstate nebel_fire_fiu invisible // can't fire rockets any more

		enablespeaker speaker_generator_blown

		wm_announce "^3The Allies have destroyed the Generator - the security doors are opening!"
		globalaccum 0 bitset 3
		trigger generator_toi remove

		wm_announce "^3Time limit extended by 14 minutes!"
		wm_set_round_timelimit	30

		wm_axis_respawntime 20
		wm_allied_respawntime 20

		wm_objective_status 3 0 2
		wm_objective_status 3 1 1

		disablespeaker speaker_generator

		setstate axisteamdoor1 invisible // remove the secure door
		setstate hint_generator_door_tm invisible // remove the hint for it

		trigger depotdoor open_door
	}
}

generator_toi
{
	spawn
	{
		wait 150
	}

	trigger remove
	{
		remove
	}
}

// =================================================
// Garage spawn point
// =================================================
garage_flag
{
	spawn
	{
		accum 0 set 0				// Who owns flag: 0-Axis, 1-Allied
		setstate garage_flag invisible
	}

	trigger axis_capture				// T	w	wouched by an Axis player
	{
		accum 0 abort_if_equal 0 		// do Axis own flag?
			
		accum 0 set 0 				// Axis own the flag
		globalaccum 0 bitreset 8  
		wm_announce "^3Axis have retaken the Tank Garage!"
		alertentity garage_spawns
		setstate garage_wobj invisible
	}

	trigger allied_capture				// Touched by an allied player
	{
	}
}

// =================================================
// Glider Trigger
// =================================================
glider_tst
{
	trigger run
	{
		globalaccum 0 abort_if_not_bitset 1

		setstate glider_tm invisible
		trigger glider_sm fly
	}
}

// =================================================
// Glider
// =================================================
glider_sm
{
// accum 0 bit 0	: 0=Alive 1=Dead
// accum 0 bit 1  : 0=Waiting 1=Flying
// accum 1		: Flight position, 0=At start
	spawn
	{
		wait 100
		setstate crash_hurt2 invisible
		setstate crash_hurt3 invisible
		setstate crash_hurt4 invisible
		setstate crash_hurt6 invisible
		setstate crash_hurt7 invisible
		setstate crash_hurt8 invisible
		setstate crash_hurt9 invisible
		setstate crash_hurt10 invisible
		setstate crash_hurt11 invisible
		setstate crash_hurt15 invisible
	}

	death
	{
		trigger self deathcheck
	
		wm_announce "^3The Glider has been destroyed!"
		globalaccum 0 bitset 0	// Enable the alertentity to allow rebirth function  v2.4.1

		trigger self crash
	}

	pain
	{
		setstate glider_smoke default
	}

	rebirth
	{
		accum 0 bitreset 0 // We're alive
	}

	trigger crash
	{
	//	pitch	(y-axis left/right bank)	- left	+ right
	//	yaw	(z-axis left/right turn)	+ left	- right	0 = North
	//	roll	(x-axis nose up/down)		+ up		- down

		setstate glider_smoke default
		trigger self crash_check

		accum 1 abort_if_less_than 12
		accum 1 abort_if_not_equal 12
		wm_announce "^3...but will make a crash landing!"
	}

	trigger crash_check
	{
		accum 1 abort_if_greater_than 11 // The plane will crash land anyway

		resetscript // will this stop crash code from executing?
		accum 0 bitset 0		// We're dead
		abortmove

		accum 1 trigger_if_equal 0 glider_sm restart
		accum 1 trigger_if_equal 1 glider_sm crash1
		accum 1 trigger_if_equal 2 glider_sm crash2
		accum 1 trigger_if_equal 3 glider_sm crash3
		accum 1 trigger_if_equal 4 glider_sm crash4
		accum 1 trigger_if_equal 5 glider_sm crash5
		accum 1 trigger_if_equal 6 glider_sm crash6
		accum 1 trigger_if_equal 7 glider_sm crash7
		accum 1 trigger_if_equal 8 glider_sm crash8
		accum 1 trigger_if_equal 9 glider_sm crash9
		accum 1 trigger_if_equal 10 glider_sm crash10
		accum 1 trigger_if_equal 11 glider_sm crash11
	}

	trigger crash1
	{
		setstate glider_puff invisible
		trigger self restart
	}

	trigger crash2
	{
		gotomarker crash_path2 300
		faceangles -10 5 -5 5000
		gotomarker crash_path2 300 wait

		trigger self explode

		setstate crash_hurt2 default
		wait 100
		setstate crash_hurt2 invisible

		trigger self restart
	}

	trigger crash3
	{
		gotomarker crash_path3 300
		faceangles -5 0 -25 4000
		gotomarker crash_path3 300 wait

		trigger self explode

		setstate crash_hurt3 default
		wait 100
		setstate crash_hurt3 invisible

		trigger self restart
	}

	trigger crash4
	{
		gotomarker crash_path4 300
		faceangles -30 15 -30 3000
		gotomarker crash_path4 300 wait

		trigger self explode

		setstate crash_hurt4 default
		wait 100
		setstate crash_hurt4 invisible

		trigger self restart
	}

	trigger crash5
	{
		gotomarker crash_path5 300
		faceangles 15 -15 -30 3000
		gotomarker crash_path5 300 wait

		trigger self explode // There is no hurt for 5
		trigger self restart
	}

	trigger crash6
	{
		gotomarker crash_path6 300
		faceangles 0 0 -15 5000
		gotomarker crash_path6 300 wait

		trigger self explode

		setstate crash_hurt6 default
		wait 100
		setstate crash_hurt6 invisible

		trigger self restart
	}

	trigger crash7
	{
		gotomarker crash_path7 300
		faceangles 30 -15 -30 3000
		gotomarker crash_path7 300 wait

		trigger self explode

		setstate crash_hurt7 default
		wait 100
		setstate crash_hurt7 invisible

		trigger self restart
	}

	trigger crash8
	{
		gotomarker crash_path8 300
		faceangles 20 -90 -30 5000
		gotomarker crash_path8 300 wait

		trigger self explode

		setstate crash_hurt8 default
		wait 100
		setstate crash_hurt8 invisible

		trigger self restart
	}

	trigger crash9
	{
		gotomarker crash_path9 300
		faceangles -0 -90 -30 5000
		gotomarker crash_path9 300 wait

		trigger self explode

		setstate crash_hurt9 default
		wait 100
		setstate crash_hurt9 invisible

		trigger self restart
	}

	trigger crash10
	{
		gotomarker crash_path10 300
		faceangles 0 -95 -15 5000
		gotomarker crash_path10 300 wait

		trigger self explode

		setstate crash_hurt10 default
		wait 100
		setstate crash_hurt10 invisible

		trigger self restart
	}

	trigger crash11
	{
		gotomarker crash_path11 300
		faceangles 15 -95 -20 3000
		gotomarker crash_path11 300 wait

		trigger self explode

		setstate crash_hurt11 default
		wait 100
		setstate crash_hurt11 invisible

		trigger self restart
	}

	trigger dispatch
	{
		accum 1 inc 1

		accum 1 trigger_if_equal 1 glider_sm fly1
		accum 1 trigger_if_equal 2 glider_sm fly2
		accum 1 trigger_if_equal 3 glider_sm fly3
		accum 1 trigger_if_equal 4 glider_sm fly4
		accum 1 trigger_if_equal 5 glider_sm fly5
		accum 1 trigger_if_equal 6 glider_sm fly6
		accum 1 trigger_if_equal 7 glider_sm fly7
		accum 1 trigger_if_equal 8 glider_sm fly8
		accum 1 trigger_if_equal 9 glider_sm fly9
		accum 1 trigger_if_equal 10 glider_sm fly10
		accum 1 trigger_if_equal 11 glider_sm fly11
		accum 1 trigger_if_equal 12 glider_sm fly12
		accum 1 trigger_if_equal 13 glider_sm fly13
		accum 1 trigger_if_equal 14 glider_sm fly14
		accum 1 trigger_if_equal 15 glider_sm fly15
	}
	
	trigger explode
	{
		trigger glider_explosion explode
	}

	trigger fly
	{
	//	pitch	(y-axis left/right bank)	- left	+ right
	//	yaw	(z-axis left/right turn)	+ left	- right	0 = North
	//	roll	(x-axis nose up/down)		+ up		- down

		accum 0 bitset 1 // We're flying
		accum 1 set 0 // Make sure we're at the start of flight path  v2.4.1
		trigger self dispatch
	}

	trigger fly1
	{
		setstate glider_puff default
		gotomarker path1 300 wait // launch along rails

		accum 0 abort_if_bitset 0 // Abort if we're dead

		setstate glider_puff invisible
		stopsound
		playsound sound/world/wind_mountain.wav looping volume 512

		trigger self keep_flying
	}

	trigger fly2
	{	
		gotomarker path2 300 
		faceangles 0 0 15 1000	// climb
		gotomarker path2 300 wait
		trigger self keep_flying
	}

	trigger fly3
	{	
		gotomarker path3 300 
		faceangles 0 0 0 3000	// level
		gotomarker path3 300 wait

		trigger self keep_flying
	}

	trigger fly4
	{	
		gotomarker path4 300 wait
		trigger self keep_flying
	}

	trigger fly5
	{	
		gotomarker path5 300 wait
		trigger self keep_flying
	}

	trigger fly6
	{	
		gotomarker path6 300 wait
		trigger self keep_flying
	}

	trigger fly7
	{	
		gotomarker path7 300 wait
		trigger self keep_flying
	}

	trigger fly8
	{	
		gotomarker path8 300
		faceangles 20 -90 0 5000	// bank and turn right
		gotomarker path8 300 wait
		trigger self keep_flying
	}

	trigger fly9
	{	
		gotomarker path9 300
		faceangles -0 -90 0 3000	// level
		gotomarker path9 300 wait
		trigger self keep_flying
	}

	trigger fly10
	{	
		gotomarker path10 300 wait
		trigger self keep_flying
	}

	trigger fly11
	{	
		gotomarker path11 300 wait
		trigger self keep_flying
	}

	trigger fly12
	{	
		gotomarker path12 300 wait
		trigger self keep_flying
	}

	trigger fly13
	{	
		gotomarker path13 300
		faceangles -0 -90 -5 1000	// land
		gotomarker path13 300 wait

		setstate glider_smoke default // burn the wreck

		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 512

		trigger self keep_flying
	}

	trigger fly14
	{	
		gotomarker path14 200
		faceangles -0 -65 0 1000	// skid slow
		wait 500
		playsound sound/movers/misc/garage_door_loop_01.wav looping volume 512
		gotomarker path14 200 wait

		trigger self keep_flying
	}

	trigger fly15
	{	
		gotomarker path15 100
		faceangles 0 0 0 1000		// slew stop
		gotomarker path15 100 wait

		stopsound
		playsound sound/movers/misc/garage_door_end_01.wav volume 512

		accum 0 bitreset 1 // We've landed
		trigger self cp_alert
		trigger self ramp_alert

		wait 6000 // v2.4.1

		trigger self explode

		setstate crash_hurt15 default
		wait 100
		setstate crash_hurt15 invisible
		trigger self restart
	}

	trigger keep_flying
	{
		accum 0 abort_if_bitset 0 // Abort if we're dead
		trigger self dispatch
	}

	trigger cp_alert
	{
		globalaccum 0 abort_if_bitset 4 // CP is already built
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
	}

	trigger ramp_alert
	{
		globalaccum 0 abort_if_not_bitset 4 // CP isn't built
		globalaccum 0 abort_if_bitset 2 // Ramp is already built
		globalaccum 0 abort_if_bitset 3 // Generator is destroyed

		wm_teamvoiceannounce 0 "battery_axis_stop_ramp"
		wm_teamvoiceannounce 1 "battery_allies_build_ramp"
	}

	trigger respot
	{
		setposition path0
		faceangles 0 0 0 1
	}

	trigger restart
	{
		stopsound

		setstate glider_smoke invisible
		accum 1 set 0 // Reset the path indicator

		kill alliedconstruct_glider
		trigger alliedconstruct_glider setup
	}
}

// =================================================
// Explosions from glider crashes v2.4.1
// =================================================
glider_explosion
{
	trigger explode
	{
		setposition glider_sm
		alertentity glider_explosion
	}
}

// =================================================
// Glider launch smoke
// =================================================
glider_puff
{
	spawn
	{
		wait 300
		setstate glider_puff invisible
	}
}

// =================================================
// Glider damaged smoke
// =================================================
glider_smoke
{
	spawn
	{
		wait 300
		setstate glider_smoke invisible
	}

	trigger follow
	{
		setposition glider_sm
	}
}

// =================================================
// Guardpost spawn point
// =================================================
guardpost_flag
{
	spawn
	{
		accum 0 set 2				// Who owns flag: 0-Axis, 1-Allied, 2-Nobody
	}

	trigger spitfire_flown
	{
		// The Spitfire has flown - Make the Guardpost Allied
		setstate guardpost_flag invisible
		setautospawn "Guardpost" 1		// Set Allies to Guardpost spawn

		accum 0 abort_if_equal 1 		// abort if Allies already owner

		setstate guardpost_wobj default
		alertentity guardpost_spawns
		alertentity guardpost_wobj		// Switch command map marker
	}

	trigger axis_capture				// Touched by an Axis player
	{
		accum 0 abort_if_equal 0 		// do Axis own flag?
		accum 0 trigger_if_equal 1 guardpost_flag axis_reclaim	// Reclaimed from Allies

		accum 0 set 0 				// Axis own the flag

		setstate guardpost_wobj default
	}

	trigger axis_reclaim
	{
		alertentity guardpost_wobj		// Switch command map marker
	}

	trigger allied_capture				// Touched by an allied player
	{
		accum 0 abort_if_equal 1 		// do Allies own flag?

		accum 0 set 1 				// Allied own the flag
		wm_announce "^3Allies are in control of the Guardpost!"

		setstate guardpost_wobj default
		alertentity guardpost_wobj		// Switch command map marker
	}
}

// =================================================
// Island spawn point
// =================================================
island_flag
{
	spawn
	{
		accum 0 set 1				// Who owns flag: 0-Axis, 1-Allied
	}

	trigger axis_capture				// Touched by an Axis player
	{
		accum 0 abort_if_equal 0 		// do Axis own flag?

		accum 0 set 0 				// Axis own the flag
		wm_announce "^3Axis have claimed the Island!"
		alertentity island_spawns
		setstate island_wobj default
	}

	trigger allied_capture				// Touched by an allied player
	{
		accum 0 abort_if_equal 1 		// do Allies own flag?

		accum 0 set 1 				// Allied own the flag
		wm_announce "^3Allies have liberated the Island!"
		alertentity island_spawns
		setstate island_wobj invisible
	}
}

// =================================================
// Nebelwerfer
// =================================================
nebel_fire_tst
{
	trigger main
	{
		trigger scriptblock2 rocket_fire
	}
}

nebel_load_tst
{
	trigger main
	{
		trigger scriptblock2 rocket_load
	}
}

nebel_resupply_arrow
{
}

nebel_resupply_tst
{
	trigger run
	{
		trigger scriptblock2 rocket_resupply
	}
}

// =================================================
// Outpost spawn point
// =================================================
outpost_flag
{
	spawn
	{
		accum 0 set 0				// Who owns flag: 0-Axis, 1-Allied
		setstate outpost_flag invisible
	}

	trigger spitfire_flown
	{
		// The Spitfire has flown - Make the Outpost Axis
		wm_announce "Axis have ^3permanently ^7claimed the Outpost!"
		setautospawn "Outpost"		0	// Set Axis to Outpost spawn
		setstate outpost_wobj default

		accum 0 abort_if_equal 0 		// abort if Axis already owner

		alertentity outpost_spawns
		wm_objective_status 6 0 1
		wm_objective_status 6 1 2

		alertentity outpost_wobj		// Switch command map marker
	}

	trigger axis_capture				// Touched by an Axis player
	{
		accum 0 abort_if_equal 0 		// do Axis own flag?

		wm_announce "^3Axis have reclaimed the Outpost!"
		accum 0 set 0 				// Axis own the flag
		wm_objective_status 6 0 1
		wm_objective_status 6 1 2

		alertentity outpost_wobj		// Switch command map marker
		wm_axis_respawntime 20
		wm_allied_respawntime 10

	//	Put the allies back into parachutes
		globalaccum 0 bitset 6 // Allies parachuting
		alertentity parachute_wobj		// Switch command map marker
		alertentity axis_parachute_spawns
		alertentity allied_parachute_spawns

		setautospawn "Outpost"		0		// Set Axis to Outpost spawn
		setautospawn "Parachute"	1		// Set Allies to Parachute spawn
	}

	trigger allied_capture				// Touched by an allied player
	{
		accum 0 abort_if_equal 1 		// do Allies own flag?

		accum 0 set 1 				// Allied own the flag
		wm_announce "^3Allies have captured the Outpost!"

		wm_objective_status 6 0 2
		wm_objective_status 6 1 1

		alertentity outpost_wobj		// Switch command map marker
		wm_axis_respawntime 15
		wm_allied_respawntime 15

	//	Put the axis into parachutes
		globalaccum 0 bitreset 6 // Axis parachuting
		alertentity parachute_wobj		// Switch command map marker
		alertentity axis_parachute_spawns
		alertentity allied_parachute_spawns

		setautospawn "Parachute"	0
		setautospawn "Outpost"		1
	}
}

pump_puff
{
	spawn
	{
		wait 300
		setstate pump_puff invisible
	}
}

// =================================================
scriptblock1
{
	trigger spitfire_flown
	{
	//	Prevent spawning at ruins, tank garage and compound
		trigger self cancel_ruins
		trigger self cancel_garage
		trigger self cancel_compound
	}

	trigger cancel_compound
	{
		setstate compound_wobj invisible
		alertentity compound_spawns
	}

	trigger cancel_garage
	{
		setstate garage_wobj invisible
		setstate garage_flag invisible

		globalaccum 0 abort_if_not_bitset 8 // Abort if owned by axis
		alertentity garage_spawns
	}

	trigger cancel_ruins
	{
		setstate ruins_wobj invisible

		globalaccum 0 abort_if_not_bitset 4 // Abort if the CP never got built
		alertentity ruins_spawns
	}
}

scriptblock2
{
// accum 0 : lowest rocket nbr on grate (1-6 7=full)
// accum 1 : next empty slot in nebelwerfer (1-6 7=full)
// accum 2 : 1=rocket firing in progress
// accum 3 : 1=rocket loading in progress

	spawn
	{
		wait 500
		accum 0 set 1
		accum 1 set 1
	}	

	//	rocket firing
	//------------------
	trigger rocket_fire
	{
		accum 3 abort_if_equal 1 // abort if loading

		accum 2 set 1 // firing

		setstate nebel_load_fiu invisible // can't load while firing
		setstate nebel_fire_fiu invisible // can't fire again until re-loaded

		enablespeaker speaker_rocket_fire

		trigger self rocket_fire1
		wait 500
		trigger self rocket_fire2
		wait 500
		trigger self rocket_fire3
		wait 500
		trigger self rocket_fire4
		wait 500
		trigger self rocket_fire5
		wait 500
		trigger self rocket_fire6
		wait 2000
		accum 1 set 1 // next empty slot 1

		accum 2 set 0  // finished firing

		disablespeaker speaker_rocket_fire
		enablespeaker speaker_rocket_fire_done

		accum 0 abort_if_equal 7 // abort if no rockets in cart
		setstate nebel_load_fiu default // rockets in cart, so allow loading
	}

	trigger rocket_fire1
	{
		setstate rocket1_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	trigger rocket_fire2
	{
		accum 1 abort_if_less_than 3
		setstate rocket2_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	trigger rocket_fire3
	{
		accum 1 abort_if_less_than 4
		setstate rocket3_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	trigger rocket_fire4
	{
		accum 1 abort_if_less_than 5
		setstate rocket4_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	trigger rocket_fire5
	{
		accum 1 abort_if_less_than 6
		setstate rocket5_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	trigger rocket_fire6
	{
		accum 1 abort_if_less_than 7
		setstate rocket6_loaded invisible
		trigger shooter1_t aim
		alertentity shooter1
	}

	//	rocket inserts
	//------------------
	trigger rocket_insert1a
	{
		setstate rocket1_loaded underconstruction
	}

	trigger rocket_insert2a
	{
		setstate rocket2_loaded underconstruction
	}

	trigger rocket_insert3a
	{
		setstate rocket3_loaded underconstruction
	}

	trigger rocket_insert4a
	{
		setstate rocket4_loaded underconstruction
	}

	trigger rocket_insert5a
	{
		setstate rocket5_loaded underconstruction
	}

	trigger rocket_insert6a
	{
		setstate rocket6_loaded underconstruction
	}

	trigger rocket_insert1b
	{
		setstate rocket1_loaded default
	}

	trigger rocket_insert2b
	{
		setstate rocket2_loaded default
	}

	trigger rocket_insert3b
	{
		setstate rocket3_loaded default
	}

	trigger rocket_insert4b
	{
		setstate rocket4_loaded default
	}

	trigger rocket_insert5b
	{
		setstate rocket5_loaded default
	}

	trigger rocket_insert6b
	{
		setstate rocket6_loaded default
	}

	//---------------------------
	trigger rocket_load
	//---------------------------
	{
		accum 2 abort_if_equal 1 // abort if firing

		accum 3 set 1 // loading

	 //	stop any loading, firing, supplying
		setstate nebel_resupply_tm invisible
		setstate nebel_resupply_arrow invisible
		setstate nebel_load_fiu invisible
		setstate nebel_fire_fiu invisible

		enablespeaker speaker_rocket_load

		accum 0 trigger_if_equal 1 scriptblock2 rocket_pickup1a
		accum 0 trigger_if_equal 2 scriptblock2 rocket_pickup2a
		accum 0 trigger_if_equal 3 scriptblock2 rocket_pickup3a
		accum 0 trigger_if_equal 4 scriptblock2 rocket_pickup4a
		accum 0 trigger_if_equal 5 scriptblock2 rocket_pickup5a
		accum 0 trigger_if_equal 6 scriptblock2 rocket_pickup6a

		accum 1 trigger_if_equal 1 scriptblock2 rocket_insert1a
		accum 1 trigger_if_equal 2 scriptblock2 rocket_insert2a
		accum 1 trigger_if_equal 3 scriptblock2 rocket_insert3a
		accum 1 trigger_if_equal 4 scriptblock2 rocket_insert4a
		accum 1 trigger_if_equal 5 scriptblock2 rocket_insert5a
		accum 1 trigger_if_equal 6 scriptblock2 rocket_insert6a

		wait 2000

		accum 0 trigger_if_equal 1 scriptblock2 rocket_pickup1b
		accum 0 trigger_if_equal 2 scriptblock2 rocket_pickup2b
		accum 0 trigger_if_equal 3 scriptblock2 rocket_pickup3b
		accum 0 trigger_if_equal 4 scriptblock2 rocket_pickup4b
		accum 0 trigger_if_equal 5 scriptblock2 rocket_pickup5b
		accum 0 trigger_if_equal 6 scriptblock2 rocket_pickup6b

		accum 1 trigger_if_equal 1 scriptblock2 rocket_insert1b
		accum 1 trigger_if_equal 2 scriptblock2 rocket_insert2b
		accum 1 trigger_if_equal 3 scriptblock2 rocket_insert3b
		accum 1 trigger_if_equal 4 scriptblock2 rocket_insert4b
		accum 1 trigger_if_equal 5 scriptblock2 rocket_insert5b
		accum 1 trigger_if_equal 6 scriptblock2 rocket_insert6b

		disablespeaker speaker_rocket_load

		accum 0 inc 1 // next available rocket on cart
		accum 1 inc 1 // next empty nebel slot

		trigger self rocket_fire_check
		setstate nebel_resupply_tm default
		setstate nebel_resupply_arrow default

		accum 3 set 0 // finished loading

		accum 1 abort_if_equal 7 // abort if nebel full
		accum 0 abort_if_equal 7 // abort if cart empty

		setstate nebel_load_fiu default // allow loading
	}

	trigger rocket_fire_check
	{
		globalaccum 0 abort_if_bitset 3 // Abort if generator is destroyed
		setstate nebel_fire_fiu default
	}

	//	rocket pickups
	//------------------
	trigger rocket_pickup1a
	{
		setstate rocket1 underconstruction
	}

	trigger rocket_pickup2a
	{
		setstate rocket2 underconstruction
	}

	trigger rocket_pickup3a
	{
		setstate rocket3 underconstruction
	}

	trigger rocket_pickup4a
	{
		setstate rocket4 underconstruction
	}

	trigger rocket_pickup5a
	{
		setstate rocket5 underconstruction
	}

	trigger rocket_pickup6a
	{
		setstate rocket6 underconstruction
	}

	trigger rocket_pickup1b
	{
		setstate rocket1 invisible
	}

	trigger rocket_pickup2b
	{
		setstate rocket2 invisible
	}

	trigger rocket_pickup3b
	{
		setstate rocket3 invisible
	}

	trigger rocket_pickup4b
	{
		setstate rocket4 invisible
	}

	trigger rocket_pickup5b
	{
		setstate rocket5 invisible
	}

	trigger rocket_pickup6b
	{
		setstate rocket6 invisible
	}

	//	rocket resupply
	//------------------
	trigger rocket_resupply
	{
		accum 0 abort_if_equal 1 // already fully supplied
		accum 3 abort_if_equal 1 // loading

		setstate nebel_resupply_tm invisible
		setstate nebel_resupply_arrow invisible
		setstate nebel_load_fiu invisible
		setstate hint_nebel invisible
		setstate exclamation_nebel invisible

		enablespeaker speaker_rocket_resupply

		accum 0 inc -1

		accum 0 trigger_if_equal 1 scriptblock2 rocket_supply1
		accum 0 trigger_if_equal 2 scriptblock2 rocket_supply2
		accum 0 trigger_if_equal 3 scriptblock2 rocket_supply3
		accum 0 trigger_if_equal 4 scriptblock2 rocket_supply4
		accum 0 trigger_if_equal 5 scriptblock2 rocket_supply5
		accum 0 trigger_if_equal 6 scriptblock2 rocket_supply6

		trigger self rocket_resupply_cart_check
		trigger self rocket_resupply_load_check
	}

	trigger rocket_resupply_cart_check
	{
	//	If the cart is full, we can't resupply further
		accum 0 abort_if_equal 1 // already fully supplied

		setstate nebel_resupply_tm default // allow resupply
		setstate nebel_resupply_arrow default
	}

	trigger rocket_resupply_load_check
	{
	//	If the nebel is firing it will enable loading when finished
		accum 2 abort_if_equal 1 // abort if firing
		accum 1 abort_if_equal 7 // abort if nebel full

		setstate nebel_load_fiu default // allow loading
	}

	trigger rocket_supply1
	{
		setstate rocket1 default
	}

	trigger rocket_supply2
	{
		setstate rocket2 default
	}

	trigger rocket_supply3
	{
		setstate rocket3 default
	}

	trigger rocket_supply4
	{
		setstate rocket4 default
	}

	trigger rocket_supply5
	{
		setstate rocket5 default
	}

	trigger rocket_supply6
	{
		setstate rocket6 default
	}
}

// =================================================
shooter1_t
{
// accum 0 : rnd (0-1)
	trigger aim
	{
		accum 0 random 2
		accum 0 trigger_if_equal 0 shooter1_t aim1
		accum 0 trigger_if_equal 1 shooter1_t aim2
	}

	trigger aim1
	{
		setposition nebel_target_1
	}

	trigger aim2
	{
		setposition nebel_target_2
	}
}

// =================================================
smoke_generator
{
	trigger run
	{
		trigger glider_smoke follow
	}
}

//===========================================
sniper_timer_tst
{
	trigger run
	{
		trigger sniper1_tm reset
		trigger sniper2_tm reset
		trigger sniper3_tm reset
		trigger sniper4_tm reset
		trigger sniper5_tm reset
		trigger sniper6_tm reset
		trigger sniper7_tm reset
		trigger sniper8_tm reset
		trigger sniper9_tm reset
		trigger sniper10_tm reset
		trigger sniper11_tm reset
		trigger sniper12_tm reset
		trigger sniper13_tm reset
		trigger sniper14_tm reset
		trigger sniper15_tm reset
		trigger sniper16_tm reset

		trigger sniper18_tm reset
		trigger sniper19_tm reset

		trigger sniper21_tm reset
	}
}

sniper1_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 1
		wait 1000
		globalaccum 1 abort_if_not_equal 1

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar1
		wait random 750 1250
		alertentity mortar2
		wait random 750 1250
		alertentity mortar3
		wait random 750 1250
		alertentity mortar4

		trigger self fired
	}
}

sniper1_tst
{
	trigger run
	{
		trigger sniper1_tm sniper_detected
	}
}

sniper2_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 2
		wait 1000
		globalaccum 1 abort_if_not_equal 2

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar5
		wait random 750 1250
		alertentity mortar6
		wait random 750 1250
		alertentity mortar7
		wait random 750 1250
		alertentity mortar8

		trigger self fired
	}
}

sniper2_tst
{
	trigger run
	{
		trigger sniper2_tm sniper_detected
	}
}

sniper3_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 3
		wait 1000
		globalaccum 1 abort_if_not_equal 3

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar9
		wait random 750 1250
		alertentity mortar10
		wait random 750 1250
		alertentity mortar11
		wait random 750 1250
		alertentity mortar12

		trigger self fired
	}
}

sniper3_tst
{
	trigger run
	{
		trigger sniper3_tm sniper_detected
	}
}

sniper4_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 4
		wait 1000
		globalaccum 1 abort_if_not_equal 4

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar13
		wait random 750 1250
		alertentity mortar14
		wait random 750 1250
		alertentity mortar15
		wait random 750 1250
		alertentity mortar16

		trigger self fired
	}
}

sniper4_tst
{
	trigger run
	{
		trigger sniper4_tm sniper_detected
	}
}

sniper5_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 5
		wait 1000
		globalaccum 1 abort_if_not_equal 5

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar17
		wait random 750 1250
		alertentity mortar18
		wait random 750 1250
		alertentity mortar19
		wait random 750 1250
		alertentity mortar20

		trigger self fired
	}
}

sniper5_tst
{
	trigger run
	{
		trigger sniper5_tm sniper_detected
	}
}

sniper6_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 6
		wait 1000
		globalaccum 1 abort_if_not_equal 6

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar21
		wait random 750 1250
		alertentity mortar22
		wait random 750 1250
		alertentity mortar23
		wait random 750 1250
		alertentity mortar24

		trigger self fired
	}
}

sniper6_tst
{
	trigger run
	{
		trigger sniper6_tm sniper_detected
	}
}

sniper7_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 7
		wait 1000
		globalaccum 1 abort_if_not_equal 7

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		// same as group 6
		alertentity mortar24
		wait random 750 1250
		alertentity mortar23
		wait random 750 1250
		alertentity mortar22
		wait random 750 1250
		alertentity mortar21

		trigger self fired
	}
}

sniper7_tst
{
	trigger run
	{
		trigger sniper7_tm sniper_detected
	}
}

sniper8_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 8
		wait 1000
		globalaccum 1 abort_if_not_equal 8

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar25
		wait random 750 1250
		alertentity mortar26
		wait random 750 1250
		alertentity mortar27
		wait random 750 1250
		alertentity mortar28

		trigger self fired
	}
}

sniper8_tst
{
	trigger run
	{
		trigger sniper8_tm sniper_detected
	}
}

sniper9_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 9
		wait 1000
		globalaccum 1 abort_if_not_equal 9

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar29
		wait random 750 1250
		alertentity mortar30
		wait random 750 1250
		alertentity mortar31
		wait random 750 1250
		alertentity mortar32

		trigger self fired
	}
}

sniper9_tst
{
	trigger run
	{
		trigger sniper9_tm sniper_detected
	}
}

sniper10_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 10
		wait 1000
		globalaccum 1 abort_if_not_equal 10

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar33
		wait random 750 1250
		alertentity mortar34
		wait random 750 1250
		alertentity mortar35
		wait random 750 1250
		alertentity mortar36

		trigger self fired
	}
}

sniper10_tst
{
	trigger run
	{
		trigger sniper10_tm sniper_detected
	}
}

sniper11_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 11
		wait 1000
		globalaccum 1 abort_if_not_equal 11

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar37
		wait random 750 1250
		alertentity mortar38
		wait random 750 1250
		alertentity mortar39
		wait random 750 1250
		alertentity mortar40

		trigger self fired
	}
}

sniper11_tst
{
	trigger run
	{
		trigger sniper11_tm sniper_detected
	}
}

sniper12_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 12
		wait 1000
		globalaccum 1 abort_if_not_equal 12

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar41
		wait random 750 1250
		alertentity mortar42
		wait random 750 1250
		alertentity mortar43
		wait random 750 1250
		alertentity mortar44

		trigger self fired
	}
}

sniper12_tst
{
	trigger run
	{
		trigger sniper12_tm sniper_detected
	}
}

sniper13_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 13
		wait 1000
		globalaccum 1 abort_if_not_equal 13

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar45
		wait random 750 1250
		alertentity mortar46
		wait random 750 1250
		alertentity mortar47
		wait random 750 1250
		alertentity mortar48

		trigger self fired
	}
}

sniper13_tst
{
	trigger run
	{
		trigger sniper13_tm sniper_detected
	}
}

sniper14_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 14
		wait 1000
		globalaccum 1 abort_if_not_equal 14

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar49
		wait random 750 1250
		alertentity mortar50
		wait random 750 1250
		alertentity mortar51
		wait random 750 1250
		alertentity mortar52

		trigger self fired
	}
}

sniper14_tst
{
	trigger run
	{
		trigger sniper14_tm sniper_detected
	}
}

sniper15_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 15
		wait 1000
		globalaccum 1 abort_if_not_equal 15

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar53
		wait random 750 1250
		alertentity mortar54
		wait random 750 1250
		alertentity mortar55
		wait random 750 1250
		alertentity mortar56

		trigger self fired
	}
}

sniper15_tst
{
	trigger run
	{
		trigger sniper15_tm sniper_detected
	}
}

sniper16_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 16
		wait 1000
		globalaccum 1 abort_if_not_equal 16

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ridge!"

		alertentity mortar57
		wait random 750 1250
		alertentity mortar58
		wait random 750 1250
		alertentity mortar59
		wait random 750 1250
		alertentity mortar60

		trigger self fired
	}
}

sniper16_tst
{
	trigger run
	{
		trigger sniper16_tm sniper_detected
	}
}

sniper18_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 18
		wait 1000
		globalaccum 1 abort_if_not_equal 18

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the ruins slope!"

		alertentity mortar65
		wait random 750 1250
		alertentity mortar66
		wait random 750 1250
		alertentity mortar67
		wait random 750 1250
		alertentity mortar68

		trigger self fired
	}
}

sniper18_tst
{
	trigger run
	{
		trigger sniper18_tm sniper_detected
	}
}

sniper19_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 19
		wait 1000
		globalaccum 1 abort_if_not_equal 19

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the compound peak!"

		alertentity mortar69
		wait random 750 1250
		alertentity mortar70
		wait random 750 1250
		alertentity mortar71
		wait random 750 1250
		alertentity mortar72

		trigger self fired
	}
}

sniper19_tst
{
	trigger run
	{
		trigger sniper19_tm sniper_detected
	}
}

sniper21_tm
{
// accum 0 : nbr of triggerings
	trigger fired
	{
		trigger self reset
		globalaccum 1 set 0
	}

	trigger reset
	{
		accum 0 set 0
	}

	trigger sniper_detected
	{
		globalaccum 1 abort_if_not_equal 0
		accum 0 inc 1
		accum 0 abort_if_less_than 3 // wait a while

		globalaccum 1 set 21
		wait 1000
		globalaccum 1 abort_if_not_equal 21

		wm_teamvoiceannounce 0 "glider_axis_covops"
		wm_teamvoiceannounce 1 "glider_allies_covops"
		wait 2000
		wm_announce "^3Mortars suppressing snipers on the compound hill!"

		alertentity mortar77
		wait random 750 1250
		alertentity mortar78
		wait random 750 1250
		alertentity mortar79
		wait random 750 1250
		alertentity mortar80

		trigger self fired
	}
}

sniper21_tst
{
	trigger run
	{
		trigger sniper21_tm sniper_detected
	}
}

// *************************************************
// ***************** TANK STUFF ********************
// *************************************************

tank_sound
{
	trigger start
	{
		trigger tank sound_start
		wait 3400
		trigger tank sound_move
	}

	trigger stop
	{
		trigger tank sound_stop
		wait 1400
		trigger tank sound_idle
	}

	trigger rebirth
	{
		trigger tank sound_rebirth
		wait 1400
		trigger tank sound_idle
	}
}

// digibob: converting truck script from goldrush over...
// ============================================================================
// accum 0, track state
// accum 1
//  - bit 0: barrier1 state		( 0 = not built,	1 = built		)
//  - bit 1: barrier2 state		( 0 = not built,	1 = built		)
//  - bit 2: spline status 		( 0 = not moving, 	1 = moving 		)
//  - bit 3: stuck check flag 	( 0 = not stuck, 	1 = stuck 		)
//  - bit 4: flag for message	( 0 = dont display, 1= display		)
//  - bit 5: blank				(									)
//  - bit 6: temp register 		(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
//  - bit 7: death status 		( 0 = alive, 		1 = dead		)
//  - bit 8: player check 		( 0 = players, 		1 = no players	)
//  - bit 9: visible state		( 0 = alive, 		1 = dead		)
// accum 2, blank
// accum 3, current movement loop position
// accum 4, stop counter
// accum 5, lockout ref counter
// accum 6, blank
// accum 7, blank
// ===========================================================================================
// spline points are spln2 -> spln78
// ===========================================================================================
// track events:
//  - tracks_forward
//  - tracks_stop
//  - tracks_turn_left
//  - tracks_turn_right


tank
{
	spawn
	{
		wait 400
	//	remapshader "models/mapobjects/tanks_sd/mg42turret" "models/mapobjects/tanks_sd/mg42turret_2"
		remapshaderflush

		followspline 0 spln1 50000 length 32 wait

		trigger tank sound_idle
		trigger tank tracks_stop

	}

	// ========================================
	// sound stuff

	trigger sound_idle
	{
		stopsound
		playsound sound/vehicles/tank/tank_idle.wav looping volume 512
	}

	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/tank/tank_revup.wav volume 196
	}

	trigger sound_move
	{
		stopsound
		playsound sound/vehicles/tank/tank_move.wav looping volume 512
	}

	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/tank/tank_revdown.wav volume 196
	}

	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/tank/tank_stop.wav volume 256
	}

	trigger sound_rebirth
	{
		stopsound
		playsound sound/vehicles/tank/tank_start.wav volume 196
	}

	// ========================================
	// ========================================


// ===========================================================================================
// ===========================================================================================
	trigger tracks_forward
	{
		accum 0 abort_if_equal 1
		accum 0 set 1

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward

		remapshaderflush
	}

	trigger tracks_stop
	{
		accum 0 abort_if_equal 0
		accum 0 set 0

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_left
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_right
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_left
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_right
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_left
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_right

		remapshaderflush
	}

	trigger tracks_turn_left
	{
		accum 0 abort_if_equal 2
		accum 0 set 2

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward

		remapshaderflush
	}

	trigger tracks_turn_right
	{
		accum 0 abort_if_equal 3
		accum 0 set 3

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_backward

		remapshaderflush
	}

// ===========================================================================================
// ===========================================================================================

	trigger run_continue
	{
		accum 3 inc 1
		globalaccum 3 inc 1

		trigger self deathcheck
		trigger self stopcheck
		trigger self move
	}


// ===========================================================================================
// movement

	trigger move_check
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3

		trigger self dispatch
	}

	trigger move
	{
		trigger self move_check

		wait 500

		trigger self move
	}

	trigger dispatch
	{
		accum 3 trigger_if_equal 0 tank run_0
		accum 3 trigger_if_equal 1 tank run_1
		accum 3 trigger_if_equal 2 tank run_2
		accum 3 trigger_if_equal 3 tank run_3
		accum 3 trigger_if_equal 4 tank run_4
		accum 3 trigger_if_equal 5 tank run_5
		accum 3 trigger_if_equal 6 tank run_6
		accum 3 trigger_if_equal 7 tank run_7
		accum 3 trigger_if_equal 8 tank run_8
		accum 3 trigger_if_equal 9 tank run_9
		accum 3 trigger_if_equal 10 tank run_10
		accum 3 trigger_if_equal 11 tank run_11
		accum 3 trigger_if_equal 12 tank run_12
		accum 3 trigger_if_equal 13 tank run_13
		accum 3 trigger_if_equal 14 tank run_14
		accum 3 trigger_if_equal 15 tank run_15
		accum 3 trigger_if_equal 16 tank run_16
		accum 3 trigger_if_equal 17 tank run_17
		accum 3 trigger_if_equal 18 tank run_18
		accum 3 trigger_if_equal 19 tank run_19
		accum 3 trigger_if_equal 20 tank run_20
		accum 3 trigger_if_equal 21 tank run_21
		accum 3 trigger_if_equal 22 tank run_22
		accum 3 trigger_if_equal 23 tank run_23
		accum 3 trigger_if_equal 24 tank run_24
		accum 3 trigger_if_equal 25 tank run_25
		accum 3 trigger_if_equal 26 tank run_26
		accum 3 trigger_if_equal 27 tank run_27
		accum 3 trigger_if_equal 28 tank run_28
		accum 3 trigger_if_equal 29 tank run_29
		accum 3 trigger_if_equal 30 tank run_30
		accum 3 trigger_if_equal 31 tank run_31
		accum 3 trigger_if_equal 32 tank run_32
		accum 3 trigger_if_equal 33 tank run_33
		accum 3 trigger_if_equal 34 tank run_34
		accum 3 trigger_if_equal 35 tank run_35
		accum 3 trigger_if_equal 36 tank run_36
		accum 3 trigger_if_equal 37 tank run_37
		accum 3 trigger_if_equal 38 tank run_38
		accum 3 trigger_if_equal 39 tank run_39
		accum 3 trigger_if_equal 40 tank run_40
		accum 3 trigger_if_equal 41 tank run_41
		accum 3 trigger_if_equal 42 tank run_42
		accum 3 trigger_if_equal 43 tank run_43
		accum 3 trigger_if_equal 44 tank run_44
		accum 3 trigger_if_equal 45 tank run_45
		accum 3 trigger_if_equal 46 tank run_46
		accum 3 trigger_if_equal 47 tank run_47
		accum 3 trigger_if_equal 48 tank run_48
		accum 3 trigger_if_equal 49 tank run_49
		accum 3 trigger_if_equal 50 tank run_50
		accum 3 trigger_if_equal 51 tank run_51
		accum 3 trigger_if_equal 52 tank run_52
		accum 3 trigger_if_equal 53 tank run_53
		accum 3 trigger_if_equal 54 tank run_54
		accum 3 trigger_if_equal 55 tank run_55
		accum 3 trigger_if_equal 56 tank run_56
		accum 3 trigger_if_equal 57 tank run_57
		accum 3 trigger_if_equal 58 tank run_58
		accum 3 trigger_if_equal 59 tank run_59
		accum 3 trigger_if_equal 60 tank run_60
		accum 3 trigger_if_equal 61 tank run_61
		accum 3 trigger_if_equal 62 tank run_62
		accum 3 trigger_if_equal 63 tank run_63
		accum 3 trigger_if_equal 64 tank run_64
		accum 3 trigger_if_equal 65 tank run_65
		accum 3 trigger_if_equal 66 tank run_66
		accum 3 trigger_if_equal 67 tank run_67
		accum 3 trigger_if_equal 68 tank run_68
		accum 3 trigger_if_equal 69 tank run_69
		accum 3 trigger_if_equal 70 tank run_70
		accum 3 trigger_if_equal 71 tank run_71
		accum 3 trigger_if_equal 72 tank run_72
		accum 3 trigger_if_equal 73 tank run_73
		accum 3 trigger_if_equal 74 tank run_74
		accum 3 trigger_if_equal 75 tank run_75
		accum 3 trigger_if_equal 76 tank run_76
		accum 3 trigger_if_equal 77 tank run_77
		accum 3 trigger_if_equal 78 tank run_78
		accum 3 trigger_if_equal 79 tank run_79
		accum 3 trigger_if_equal 80 tank run_80
		accum 3 trigger_if_equal 81 tank run_81
		accum 3 trigger_if_equal 82 tank run_82
		accum 3 trigger_if_equal 83 tank run_83
		accum 3 trigger_if_equal 84 tank run_84
		accum 3 trigger_if_equal 85 tank run_85
	}

	trigger run_0
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln2 50 wait length 32
		accum 1 bitreset 2

		// ************************
		trigger game_manager allies_steal_tank
		// ************************

		trigger self run_continue
	}

	trigger run_1
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln3 50 wait length 32
		accum 1 bitreset 2

		// **********************************
		trigger tank stuck_check_barrier1_built_msg
		// **********************************

		trigger self run_continue
	}

	trigger run_2
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln4 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_3
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln5 50 wait length 32
		accum 1 bitreset 2

		// **********************************
		trigger defense1 remove
		// **********************************

		trigger self run_continue
	}

	trigger run_4
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln6 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_5
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln7 50 wait length 32
		accum 1 bitreset 2

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_tank_barrier1"

		wm_teamvoiceannounce 1 "goldrush_allies_tank_barrier1"
		// *---------------------------------------------------------------------------------*

		trigger self run_continue
	}

	trigger run_6
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln8 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_7
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln9 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_8
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln10 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_9
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln11 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_10
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln12 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_11
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln13 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_12
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln14 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_13
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln15 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_14
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln16 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_15
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln17 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_16
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln18 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_17
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln19 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_18
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln20 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_19
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln21 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_20
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln22 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_21
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln23 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_22
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln24 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_23
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln25 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_24
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln26 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_25
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln27 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_26
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln28 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_27
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln29 50 wait length 32
		accum 1 bitreset 2

		enablespeaker speaker_spitfire

		trigger outpost_flag spitfire_flown
		trigger guardpost_flag spitfire_flown
		trigger scriptblock1 spitfire_flown
		globalaccum 0 bitset 7

		trigger self run_continue
	}

	trigger run_28
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln30 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_29
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln31 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_30
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln32 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_31
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln33 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_32
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln34 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_33
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln35 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_34
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln36 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_35
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln37 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_36
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln38 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_37
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln39 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_38
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln40 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_39
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln41 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_40
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln42 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_41
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln43 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_42
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln44 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_43
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln45 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_44
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln46 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_45
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln47 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_46
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln48 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_47
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln49 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_48
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln50 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_49
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln51 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_50
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln52 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_51
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln53 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_52
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln54 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_53
	{
		trigger self tracks_turn_left

		accum 1 bitset 2
		followspline 0 spln55 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_54
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln56 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_55
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln57 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_56
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln58 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_57
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln59 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_58
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln60 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_59
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln61 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_60
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln62 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_61
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln63 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_62
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln64 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_63
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln65 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_64
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln66 50 wait length 32
		accum 1 bitreset 2

		// **********************************
		trigger tank stuck_check_barrier2_built_msg
		// **********************************

		trigger self run_continue
	}

	trigger run_65
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln67 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_66
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln68 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_67
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln69 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_68
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln70 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_69
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln71 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_70
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln72 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_71
	{
		trigger self tracks_forward

		// **********************************
		trigger defense2 remove
		// **********************************

		accum 1 bitset 2
		followspline 0 spln73 50 wait length 32
		accum 1 bitreset 2

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_tank_barrier2"

		wm_teamvoiceannounce 1 "goldrush_allies_tank_barrier2"
		// *---------------------------------------------------------------------------------*

		trigger self run_continue
	}

	trigger run_72
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln74 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_73
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln75 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_74
	{
		trigger self tracks_turn_left

		accum 1 bitset 2
		followspline 0 spln76 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_75
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln77 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_76
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln78 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_77
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln79 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_78
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln80 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_79
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln81 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_80
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln82 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_81
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln83 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_82
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln84 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_83
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln85 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_84
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln86 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_85
	{
		trigger self tracks_forward

		accum 1 bitset 2
		followspline 0 spln87 50 wait length 32
		accum 1 bitreset 2

		trigger self script_lockout

		trigger self 		tracks_stop
		trigger tank_sound 	stop

// 2Bit start
		disablespeaker speaker_spitfire
		enablespeaker speaker_spitfire

		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom

		wait 900

		trigger tank_turret turn

		wait 6000
		trigger game_manager allies_win
// 2Bit end

		accum 3 inc 1
		globalaccum 3 inc 1
	}

// ===========================================================================================
// ===========================================================================================

// ===========================================================================================
// stuck checking
// digibob: since we cant return variables, just use bit 3 of accum 1 as a register... mmmm assembly...
	trigger stuck_check
	{
		accum 1 bitreset 3

		trigger self stuck_check_barrier1_built
		trigger self stuck_check_barrier2_built
		trigger self stuck_check_scriptlockout
		trigger self stuck_check_finished
	}

	trigger stuck_check_finished
	{
		accum 3 abort_if_less_than 86

		accum 1 bitset 3
	}

	trigger stuck_check_scriptlockout
	{
		accum 5 abort_if_equal 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier1_built
	{
		accum 3 abort_if_not_equal 2

		accum 1 abort_if_not_bitset 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier1_built_msg
	{
		accum 1 abort_if_not_bitset 0

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroy"
		// *---------------------------------------------------------------------------------*
	}

	trigger stuck_check_barrier2_built
	{
		accum 3 abort_if_not_equal 71

		accum 1 abort_if_not_bitset 1

		accum 1 bitset 3
	}

	trigger stuck_check_barrier2_built_msg
	{
		accum 1 abort_if_not_bitset 1

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroy"
		// *---------------------------------------------------------------------------------*
	}

// ===========================================================================================
// stop check

	trigger stopcheck_setup
	{
		//accum 1 bitset 6			// stop if we're stuck/no-one's pushing :)

		accum 1 abort_if_bitset 8		// no one in the trigger, abort

		trigger self stuck_check		// call the stop check function
		accum 1 abort_if_bitset 3		// we're stuck so break out

		accum 1 bitreset 6			// we're free to move
	}

	trigger stopcheck
	{
		trigger self stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger self script_lockout

		// Any just stopped moving stuff goes here
		trigger tank_sound 	stop
		trigger self 		tracks_stop
		startanimation 45 	10 	15 nolerp norandom
		wait 666
		startanimation 0 	1 	15 nolerp norandom
		wait 900

		trigger self script_lockout_stop
		resetscript
	}

// ===========================================================================================
// ===========================================================================================
// script lockouts

	trigger script_lockout
	{
		accum 5 inc 1
	}

	trigger script_lockout_stop
	{
		accum 5 inc -1
	}

// ===========================================================================================
// ===========================================================================================
// enable/disable

	trigger tank_enable
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3 	// stuck check

		accum 4 set 0				// reset stop counter
		accum 1 bitreset 8			// reset stop check

		accum 1 abort_if_bitset 2 	// already following spline
		accum 5 abort_if_not_equal 0	// are we not in a script lockout?

		accum 1 abort_if_bitset 7 	// death check

		// Any just started moving stuff goes here

		trigger self script_lockout

		trigger tank_sound start

		startanimation 55 10 15 nolerp norandom
		wait 666
		startanimation 5 40 15 nolerp norandom
		wait 500
		trigger self tracks_forward

		trigger self script_lockout_stop

		trigger self move
	}

	trigger tank_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 4

		accum 1 bitset 8			// set stop check

		trigger self deathcheck
	}

// ===========================================================================================
// ===========================================================================================
// death / rebirth

	rebirth
	{
		accum 1 bitreset 9 // we're visibly alive
		accum 1 bitreset 7 // we're alive again

		trigger self script_lockout

		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks.md3

		setstate tank_smoke invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_tank_stop"

		wm_teamvoiceannounce 0 "axis_hq_tank_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_tank_repaired"

		wm_removeteamvoiceannounce 1 "allies_hq_tank_damaged_axis"
		// *---------------------------------------------------------------------------------*

		trigger tank_sound rebirth
		wait 500

		trigger self script_lockout_stop
	}

	death
	{
		accum 1 bitset 7
	}

	trigger deathcheck
	{
		accum 1 abort_if_not_bitset 7	// are we dead?
		accum 1 abort_if_bitset 9		// are we not already visibly dead?
		accum 1 abort_if_bitset 2		// are we not following a spline?
		accum 5 abort_if_not_equal 0	// are we not in a script lockout?

		accum 1 bitset 9				// we're now visibly dead

		trigger self deathcheck_message
		accum 1 bitset 4

		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks2.md3

		setstate tank_smoke default

		kill tank_construct

		trigger self sound_death
		trigger self tracks_stop

		trigger self script_lockout

		trigger self tracks_stop
		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom

		trigger self script_lockout_stop

		resetscript
	}

	trigger deathcheck_message
	{
		// 2Bit start
		// accum 1 abort_if_not_bitset 4
		// 2Bit end

		wm_announce "The Tank has been damaged!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_teamvoiceannounce 0 "axis_hq_tank_damaged"

		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_tank_stop"
		// *---------------------------------------------------------------------------------*
	}

	trigger startfire
	{
		startanimation 67 8 10 nolerp norandom noloop
	}

	trigger stopfire
	{
		startanimation 0 1 15 nolerp norandom
	}

	trigger enable_stage2
	{
		accum 1 bitreset 0
	}

	trigger disable_stage2
	{
		accum 1 bitset 0
	}

	trigger enable_stage4
	{
		accum 1 bitreset 1
	}

	trigger disable_stage4
	{
		accum 1 bitset 1
	}
}

tank_trigger
{
	spawn
	{
		wait 500

		attachtotag tank_shell tag_turret

		trigger tank_trigger bot_goal_loop
	}

	trigger bot_goal_loop
	{
		wait 4000	// check every 4 seconds
		trigger tank bot_active_check
		trigger tank_trigger bot_goal_loop
	}
}

tank_build
{
	spawn
	{
		wait 500

		attachtotag tank_shell tag_turret
	}
}

tank_construct
{
	spawn
	{
		wait 1000

		// 2Bit start
		// kill tank
		// 2Bit end

		constructible_class 2
		constructible_health 1200
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity tank

		wm_announce "The Tank has been repaired!"
	}
}

tank_shell
{
	spawn
	{
		wait 400
		attachtotag tank tag_tank
	}
}

tank_turret
{
	spawn
	{
		wait 500

		attachtotag tank_shell tag_turret
	}

	trigger turn
	{
		wait 1000

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 340 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav

		//2Bit start
//		wait 500

//		trigger tank startfire
//		playsound sound/vehicles/tank/tank_fire.wav
//		trigger boomtrigger boom_all		// triggers the hurts around bank explosions (each has its own wait for timing)
//		trigger tank_flash run
		//2Bit end
	}

	trigger blow_doors
	{
		setstate tank_flash invisible

		wait 200
		trigger tank stopfire

		alertentity bank_door1
		setstate doorframe invisible
		setstate doorframe_damaged default

		wm_announce "Allied team has destroyed the Bank Doors!"

		wm_objective_status 3 0 2
		wm_objective_status 3 1 1

		wm_set_main_objective		4	0
		wm_set_main_objective		4	1

		wait 100
		trigger bank_door2_damaged bankbackboom

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 0 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav
		trigger tank sound_death
		trigger tank script_lockout_stop
	}
}

tank_flash
{
	spawn
	{
		setstate tank_flash invisible
	}

	trigger run
	{
		setstate tank_flash default
 		attachtotag tank_turret tag_flash
		faceangles 0 90 0 50

		wait 50

		trigger tank_turret blow_doors
	}
}

tank_disabler
{
	trigger run
	{
		trigger tank tank_disable
	}
}

tank_enabler
{
	trigger run
	{
		trigger tank tank_enable
	}
}

tank_smoke
{
	spawn
	{
		wait 300
		attachtotag tank_shell tag_smoke
		setstate tank_smoke invisible
	}
}

// *********************************************
// **************** CONSTRUCTIBLES *************
// *********************************************

defense1
{
	spawn
	{
		wait 400
		trigger defense1 setup

		constructible_class 3
	}

	trigger setup
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
	}

	buildstart final
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
	}

	built final
	{
		setstate defense1_materials invisible
		setstate defense1_materials_clip invisible
		setstate defense1_flag invisible

		trigger tank disable_stage2

		wm_announce "Tank Barrier #1 has been constructed."

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_tankbar_constructed"

		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbars_construct"
		// *---------------------------------------------------------------------------------*
	}

	decayed final
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
	}

	death
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default

		trigger tank enable_stage2

		wm_announce "Tank Barrier #1 has been destroyed."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_tankbar_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_tankbar_destroyed"

		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroyed"
		// *---------------------------------------------------------------------------------*
	}

	trigger remove
	{
		setstate defense1_toi invisible
		setstate defense1_materials invisible
		setstate defense1_materials_clip invisible
		setstate defense1_flag invisible
		remove
	}
}

defense2
{
	spawn
	{
		wait 400
		trigger defense2 setup

		constructible_class 3
	}

	trigger setup
	{
		setstate defense2_materials default
		setstate defense2_materials_clip default
		setstate defense2_flag default
	}

	buildstart final
	{
		setstate defense2_materials default
		setstate defense2_materials_clip default
		setstate defense2_flag default
	}

	built final
	{
		setstate defense2_materials invisible
		setstate defense2_materials_clip invisible
		setstate defense2_flag invisible

		trigger tank disable_stage4

		wm_announce "Tank Barrier #2 has been constructed."

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_tankbar_constructed"

		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbars_construct"
		// *---------------------------------------------------------------------------------*
	}

	decayed final
	{
		setstate defense2_materials default
		setstate defense2_materials_clip default
		setstate defense2_flag default
	}

	death
	{
		setstate defense2_materials default
		setstate defense2_materials_clip default
		setstate defense2_flag default

		trigger tank enable_stage4

		wm_announce "Tank Barrier #2 has been destroyed."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_tankbar_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_tankbar_destroyed"

		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroyed"
		// *---------------------------------------------------------------------------------*
	}

	trigger remove
	{
		setstate defense2_toi invisible
		setstate defense2_materials invisible
		setstate defense2_materials_clip invisible
		setstate defense2_flag invisible
		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_tankbars_construct"

		wm_removeteamvoiceannounce 1 "goldrush_allies_tankbar_destroy"
		wm_removeteamvoiceannounce 1 "goldrush_allies_tankbars_destroy"
		// *---------------------------------------------------------------------------------*

		remove
	}
}
